package com.tanhua.commons;

import com.tanhua.commons.properties.*;
import com.tanhua.commons.templates.*;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

@Configuration
@EnableConfigurationProperties({SmsProperties.class,
        OssProperties.class,
        FaceProperties.class,
        HuanXinProperties.class,
        HuaWeiUGCProperties.class})
public class CommonsAutoConfiguration {
    //注册短信模板对象
    @Bean
    public SmsTemplate smsTemplate(SmsProperties smsProperties){
        SmsTemplate smsTemplate = new SmsTemplate(smsProperties);
        smsTemplate.init();
        return smsTemplate;
    }
    //注册oss短信功能对象
    @Bean
    public OssTemplate ossTemplate(OssProperties ossProperties) {
        return  new OssTemplate(ossProperties);
    }

    //人脸识别模板对象
    @Bean
    public FaceTemplate faceTemplate(FaceProperties faceProperties) {
        return new FaceTemplate(faceProperties);
    }

    //环信模板对象
    @Bean
    public HuanXinTemplate huanXinTemplate(HuanXinProperties huanXinProperties){
        return new HuanXinTemplate(huanXinProperties);
    }

    //华为动态审核
    @Bean
    public HuaWeiUGCTemplate huaWeiUGCTemplate(HuaWeiUGCProperties huaWeiUGCProperties) {
        return new HuaWeiUGCTemplate(huaWeiUGCProperties);
    }

    //环信通讯需要用到
    @Bean
    public RestTemplate restTemplate(RestTemplateBuilder builder){
        return builder.build();
    }
}